<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="query.nurscareRegnName" clearable size="small" placeholder="照护区名称" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="query.nurscareRegnType" clearable filterable placeholder="请选择项目类别" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in dict.PRIC_NURSCARE_REGN_TYPE"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
          <!--          <el-form-item label="照护区号">
            <el-input v-model="form.nurscareRegnNo" style="width: 320px;" />
          </el-form-item>-->
          <el-form-item label="照护区名称" prop="nurscareRegnName">
            <el-input v-model="form.nurscareRegnName" style="width: 320px;" />
          </el-form-item>
          <el-form-item label="照护区类型" prop="nurscareRegnType">
            <el-select v-model="form.nurscareRegnType" filterable placeholder="请选择" style="width: 320px;">
              <el-option
                v-for="item in dict.PRIC_NURSCARE_REGN_TYPE"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="房间数" prop="bedVal">
            <el-input-number v-model="form.roomCnt" :step="1" style="width: 320px;" />
          </el-form-item>
          <el-form-item label="床位数" prop="bedVal">
            <el-input-number v-model="form.bedVal" :step="1" style="width: 320px;" />
          </el-form-item>
          <el-form-item label="护理员人数" prop="nurscarePsnCnt">
            <el-input-number v-model="form.nurscarePsnCnt" :step="1" style="width: 320px;" />
          </el-form-item>
          <el-form-item label="描述">
            <el-input v-model="form.dscr" style="width: 320px;" />
          </el-form-item>
          <!--          <el-form-item label="医保区划">
            <el-input v-model="form.admdvs" style="width: 320px;" />
          </el-form-item>-->
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <!--        <el-table-column prop="nurscareOrgNo" label="护理机构编号" />
        <el-table-column prop="nurscareRegnNo" label="照护区号" />-->
        <el-table-column prop="nurscareRegnName" label="照护区名称" />
        <el-table-column prop="nurscareRegnType" label="照护区类型">
          <template slot-scope="scope">
            {{ dict.label.PRIC_NURSCARE_REGN_TYPE[scope.row.nurscareRegnType] }}
          </template>
        </el-table-column>
        <el-table-column prop="roomCnt" label="房间数" />
        <el-table-column prop="bedVal" label="床位数" />
        <el-table-column prop="nurscarePsnCnt" label="护理员人数" />
        <el-table-column prop="dscr" label="描述" />
        <!--        <el-table-column prop="crtername" label="创建人姓名" />-->
        <el-table-column prop="opttime" label="经办时间" />
        <!--        <el-table-column prop="admdvs" label="医保区划" />-->
        <el-table-column prop="valiflag" label="有效标志">
          <template slot-scope="scope">
            {{ dict.label.PRIC_VALI_FLAG[scope.row.valiflag] }}
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','pricRegn:edit','pricRegn:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudPricRegn from '@/api/business/pricRegn'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { pricRegnId: null, nurscareOrgNo: null, nurscareOrgId: null, nurscareRegnNo: null, nurscareRegnName: null, nurscareRegnType: null, longtermOrgNurscareRegnId: null, roomCnt: null, bedVal: null, nurscarePsnCnt: null, dscr: null, rid: null, crtetime: null, updttime: null, crterid: null, crtername: null, crteoptinsno: null, opterid: null, optername: null, opttime: null, optinsno: null, admdvs: null, valiflag: null, dataver: null, ywlx: null, lrr: null, lrrxm: null, lrbm: null, lrbmmc: null, lrsj: null, gxr: null, gxrxm: null, gxbm: null, gxbmmc: null, gxsj: null, sfyx: null, bz: null }
export default {
  name: 'PricRegn',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['PRIC_NURSCARE_REGN_TYPE', 'PRIC_VALI_FLAG'],
  cruds() {
    return CRUD({ title: '照护区', url: 'api/pricRegn', idField: 'pricRegnId', sort: 'pricRegnId,desc', crudMethod: { ...crudPricRegn }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'pricRegn:add'],
        edit: ['admin', 'pricRegn:edit'],
        del: ['admin', 'pricRegn:del']
      },
      rules: {
        nurscareRegnName: [
          { required: true, message: '照护区名称必填', trigger: 'blur' }
        ],
        nurscareRegnType: [
          { required: true, message: '照护区类型必填', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
